﻿Option Strict On
Option Explicit On 

Imports IP.Core.IPCommon
Imports IP.Core.IPException


Class f111_system_admin_main
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call
        format_controls()
    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents m_c1toolbar As C1.Win.C1Command.C1ToolBar
    Friend WithEvents imageList As System.Windows.Forms.ImageList
    Friend WithEvents m_cmd_user As C1.Win.C1Command.C1Command
    Friend WithEvents m_c1cmd_holder As C1.Win.C1Command.C1CommandHolder
    Friend WithEvents m_cmd_usergroup As C1.Win.C1Command.C1Command
    Friend WithEvents m_cmd_sys_privileges As C1.Win.C1Command.C1Command
    Friend WithEvents C1CommandLink1 As C1.Win.C1Command.C1CommandLink
    Friend WithEvents m_pnl_main As System.Windows.Forms.Panel
    Friend WithEvents C1CommandLink2 As C1.Win.C1Command.C1CommandLink
    Friend WithEvents C1CommandLink3 As C1.Win.C1Command.C1CommandLink
    Friend WithEvents C1CommandLink4 As C1.Win.C1Command.C1CommandLink
    Friend WithEvents m_timer_close_the_form As System.Windows.Forms.Timer
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(f111_system_admin_main))
        Me.m_c1toolbar = New C1.Win.C1Command.C1ToolBar
        Me.C1CommandLink1 = New C1.Win.C1Command.C1CommandLink
        Me.m_cmd_usergroup = New C1.Win.C1Command.C1Command
        Me.C1CommandLink2 = New C1.Win.C1Command.C1CommandLink
        Me.m_cmd_sys_privileges = New C1.Win.C1Command.C1Command
        Me.C1CommandLink3 = New C1.Win.C1Command.C1CommandLink
        Me.m_cmd_user = New C1.Win.C1Command.C1Command
        Me.imageList = New System.Windows.Forms.ImageList(Me.components)
        Me.m_c1cmd_holder = New C1.Win.C1Command.C1CommandHolder
        Me.m_pnl_main = New System.Windows.Forms.Panel
        Me.m_timer_close_the_form = New System.Windows.Forms.Timer(Me.components)
        Me.C1CommandLink4 = New C1.Win.C1Command.C1CommandLink
        CType(Me.m_c1cmd_holder, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'm_c1toolbar
        '
        Me.m_c1toolbar.Border.Style = C1.Win.C1Command.BorderStyleEnum.Inset
        Me.m_c1toolbar.CommandHolder = Nothing
        Me.m_c1toolbar.CommandLinks.Add(Me.C1CommandLink1)
        Me.m_c1toolbar.CommandLinks.Add(Me.C1CommandLink2)
        Me.m_c1toolbar.CommandLinks.Add(Me.C1CommandLink3)
        Me.m_c1toolbar.Dock = System.Windows.Forms.DockStyle.Top
        Me.m_c1toolbar.Location = New System.Drawing.Point(0, 0)
        Me.m_c1toolbar.Movable = False
        Me.m_c1toolbar.Name = "m_c1toolbar"
        Me.m_c1toolbar.Size = New System.Drawing.Size(888, 38)
        Me.m_c1toolbar.Text = "C1ToolBar1"
        '
        'C1CommandLink1
        '
        Me.C1CommandLink1.ButtonLook = CType((C1.Win.C1Command.ButtonLookFlags.Text Or C1.Win.C1Command.ButtonLookFlags.Image), C1.Win.C1Command.ButtonLookFlags)
        Me.C1CommandLink1.Command = Me.m_cmd_usergroup
        '
        'm_cmd_usergroup
        '
        Me.m_cmd_usergroup.ImageIndex = 10
        Me.m_cmd_usergroup.Name = "m_cmd_usergroup"
        Me.m_cmd_usergroup.Text = "Nhóm Người sử dụng"
        Me.m_cmd_usergroup.ToolTipText = "Quản trị nhóm người sử dụng School Management"
        '
        'C1CommandLink2
        '
        Me.C1CommandLink2.ButtonLook = CType((C1.Win.C1Command.ButtonLookFlags.Text Or C1.Win.C1Command.ButtonLookFlags.Image), C1.Win.C1Command.ButtonLookFlags)
        Me.C1CommandLink2.Command = Me.m_cmd_sys_privileges
        '
        'm_cmd_sys_privileges
        '
        Me.m_cmd_sys_privileges.ImageIndex = 12
        Me.m_cmd_sys_privileges.Name = "m_cmd_sys_privileges"
        Me.m_cmd_sys_privileges.Text = "Phân quyền School Management"
        Me.m_cmd_sys_privileges.ToolTipText = "Các phân quyền của School Management - Chỉ xem"
        '
        'C1CommandLink3
        '
        Me.C1CommandLink3.ButtonLook = CType((C1.Win.C1Command.ButtonLookFlags.Text Or C1.Win.C1Command.ButtonLookFlags.Image), C1.Win.C1Command.ButtonLookFlags)
        Me.C1CommandLink3.Command = Me.m_cmd_user
        '
        'm_cmd_user
        '
        Me.m_cmd_user.ImageIndex = 11
        Me.m_cmd_user.Name = "m_cmd_user"
        Me.m_cmd_user.Text = "Người sử dụng"
        Me.m_cmd_user.ToolTipText = "Quản trị người sử dụng hệ thống School Management"
        '
        'imageList
        '
        Me.imageList.ImageStream = CType(resources.GetObject("imageList.ImageStream"), System.Windows.Forms.ImageListStreamer)
        Me.imageList.TransparentColor = System.Drawing.Color.Transparent
        Me.imageList.Images.SetKeyName(0, "")
        Me.imageList.Images.SetKeyName(1, "")
        Me.imageList.Images.SetKeyName(2, "")
        Me.imageList.Images.SetKeyName(3, "")
        Me.imageList.Images.SetKeyName(4, "")
        Me.imageList.Images.SetKeyName(5, "")
        Me.imageList.Images.SetKeyName(6, "")
        Me.imageList.Images.SetKeyName(7, "")
        Me.imageList.Images.SetKeyName(8, "")
        Me.imageList.Images.SetKeyName(9, "")
        Me.imageList.Images.SetKeyName(10, "")
        Me.imageList.Images.SetKeyName(11, "")
        Me.imageList.Images.SetKeyName(12, "")
        '
        'm_c1cmd_holder
        '
        Me.m_c1cmd_holder.Commands.Add(Me.m_cmd_user)
        Me.m_c1cmd_holder.Commands.Add(Me.m_cmd_usergroup)
        Me.m_c1cmd_holder.Commands.Add(Me.m_cmd_sys_privileges)
        Me.m_c1cmd_holder.ImageList = Me.imageList
        Me.m_c1cmd_holder.Owner = Me
        '
        'm_pnl_main
        '
        Me.m_pnl_main.Dock = System.Windows.Forms.DockStyle.Fill
        Me.m_pnl_main.Location = New System.Drawing.Point(0, 38)
        Me.m_pnl_main.Name = "m_pnl_main"
        Me.m_pnl_main.Size = New System.Drawing.Size(888, 503)
        Me.m_pnl_main.TabIndex = 1
        '
        'm_timer_close_the_form
        '
        '
        'f111_system_admin_main
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(888, 541)
        Me.Controls.Add(Me.m_pnl_main)
        Me.Controls.Add(Me.m_c1toolbar)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.Name = "f111_system_admin_main"
        Me.Text = "M111 - Quan tri he thong"
        CType(Me.m_c1cmd_holder, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

#Region "Public Interface"
    Public Sub display()
        Me.ShowDialog()
    End Sub
#End Region

#Region "Members"
    'Private m_frm_users As New f114_quan_ly_user
    'Private m_frm_usergroup As New f109_ht_nhom_nguoi_su_dung
    'Private m_frm_sys_priv As New f108_phan_quyen_he_thong
    Private WithEvents m_frm_current_form As Form
    Private m_b_close_form_display_other As Boolean = False
#End Region

#Region "Private"

    Private Sub format_controls()
        CControlFormat.setFormStyle(Me, New CApplicationContext, IPFormStyle.DockableTopForm)
        'CControlFormat.setFormStyle(Me, IPFormStyle.DockableTopForm)
    End Sub

    Private Sub display_users()
        Dim v_frm As New f114_quan_ly_user
        init_display_form(v_frm)
        display_form(v_frm)
        v_frm.Dock = DockStyle.Fill
    End Sub

    Private Sub display_system_privileges()
        Dim v_frm As New f108_phan_quyen_he_thong
        init_display_form(v_frm)
        display_form(v_frm)
        v_frm.Dock = DockStyle.Fill
    End Sub

    Private Sub display_usergroups()
        Dim v_frm As New f109_ht_nhom_nguoi_su_dung
        init_display_form(v_frm)
        display_form(v_frm)
        v_frm.Dock = DockStyle.Fill
    End Sub


    Private Sub init_display_form(ByVal i_form As Form)
        i_form.WindowState = FormWindowState.Maximized
        i_form.FormBorderStyle = FormBorderStyle.None
        i_form.TopLevel = False
        i_form.FormBorderStyle = FormBorderStyle.None
        AddHandler i_form.Closed, AddressOf Me.m_frm_current_form_Closed
    End Sub
    Private Sub set_form_initial()
        'init_display_form(m_frm_users)
        'init_display_form(m_frm_usergroup)
        'init_display_form(m_frm_sys_priv)
        AddHandler m_cmd_user.Click, AddressOf Me.m_cmd_user_Click
        AddHandler m_cmd_usergroup.Click, AddressOf Me.m_cmd_usergroup_Click
        AddHandler m_cmd_sys_privileges.Click, AddressOf Me.m_cmd_sys_privileges_Click
    End Sub

    Private Sub display_form(ByVal i_form_2_be_displayed As Form)
        Try
            If Not (m_frm_current_form Is i_form_2_be_displayed) Then
                m_b_close_form_display_other = True
                'close without closing the parent form
                If Not m_frm_current_form Is Nothing Then
                    m_frm_current_form.Close()
                End If
                m_frm_current_form = i_form_2_be_displayed
                'display current form
                Dim v_displayable As I_DisplayableInPanel = CType(m_frm_current_form, I_DisplayableInPanel)
                m_pnl_main.Controls.Clear()
                m_pnl_main.Controls.Add(m_frm_current_form)
                v_displayable.display_in_panel()
                '
                m_b_close_form_display_other = False
            End If
        Catch v_e As Exception
            Throw v_e
        End Try
    End Sub

#End Region

    '''
    ''' EVENT HANDLERS
    ''' 

    Private Sub f111_system_admin_main_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            set_form_initial()
            display_usergroups()
        Catch v_e As Exception
            CSystemLog_301.ExceptionHandle(v_e)
        End Try
    End Sub

    Private Sub m_cmd_user_Click(ByVal sender As Object, ByVal e As C1.Win.C1Command.ClickEventArgs)
        Try
            display_users()
        Catch v_e As Exception
            CSystemLog_301.ExceptionHandle(v_e)
        End Try
    End Sub

    Private Sub m_cmd_usergroup_Click(ByVal sender As Object, ByVal e As C1.Win.C1Command.ClickEventArgs)
        Try
            display_usergroups()
        Catch v_e As Exception
            CSystemLog_301.ExceptionHandle(v_e)
        End Try
    End Sub

    Private Sub m_cmd_sys_privileges_Click(ByVal sender As Object, ByVal e As C1.Win.C1Command.ClickEventArgs)
        Try
            display_system_privileges()
        Catch v_e As Exception
            CSystemLog_301.ExceptionHandle(v_e)
        End Try
    End Sub

    Private Sub m_frm_current_form_Closed(ByVal sender As Object, ByVal e As System.EventArgs)
        If Not m_b_close_form_display_other Then
            m_timer_close_the_form.Enabled = True
            m_timer_close_the_form.Start()
        End If
    End Sub





    'Private Sub f111_system_admin_main_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
    '    If m_pnl_main.Controls.Count > 0 Then
    '        m_pnl_main.Controls.Clear()
    '        If Not m_b_close_form_display_other _
    '            And Not m_frm_current_form Is Nothing Then
    '            m_frm_current_form.Close()
    '        End If
    '    End If
    'End Sub

    Private Sub m_timer_close_the_form_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles m_timer_close_the_form.Tick
        m_timer_close_the_form.Enabled = False
        m_timer_close_the_form.Stop()
        If Me.m_pnl_main.Controls().Count > 0 Then
            Me.m_pnl_main.Controls().Clear()
        End If
        Me.m_pnl_main = Nothing
        Me.Close()
    End Sub


End Class


